package com.kfm.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/student")
public class StudentServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String type = req.getParameter("type");
        switch (type) {
            case "insert" -> insert(req, resp);
            case "edit" -> edit(req, resp);
        }
    }

    private void insert(HttpServletRequest req, HttpServletResponse resp) {
        System.out.println("执行新增");
    }

    private void edit(HttpServletRequest req, HttpServletResponse resp) {
        System.out.println("执行修改");
    }
}
